home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
prodpack.zip
/
DB4PPSRC.EXE
/
_ODOMET.PRG
< prev
next >
Wrap
Text File
|
1993-05-04
|
4KB
|
133 lines
*' $Header: $
PROCEDURE _Odomet
*-------------------------------------------------------------------------
* NAME
* _Odomet - Display an odometer for operation status
*
* DESCRIPTION
* _Odomet will display an Odometer in a window to show the progress
* of an operation. _Odomet uses global variables versus parameter
* passing for performance reasons. The odometer will always start
* at row 9.
*
* GLOBAL VARIABLES
* gn_OdMax = The maximum value for the odometer.
* gn_OdCur = The current value of the odometer. The percentage of
* completion is based on gn_OdCur / gn_OdMax. A value
* of 0 will activate the odometer window. When the value
* equals gn_OdMax, the window will go away.
* gc_OdText = An optional message to display. The message is painted
* when gn_OdCur is 0.
* gn_OdLeft = The left most column of the odometer border inside of
* the window. This avoid having to calculate the value
* during each iteration.
* gc_OdBoxCl = Original color of box
*
* EXAMPLE
*
* gn_OdMax = 100
* gn_OdCur = 0
* gn_OdLeft = 0 && Altered by _Odomet
* gn_OdRight = 0 && Altered by _Odomet
* gn_OdBoxCl = "" && Altered by _Odomet
* gc_OdText = [Checking the form fields]
*
* DO _Odomet
*
* ln = 1
* DO WHILE ln <= gn_OdMax
* ....
* ln = ln + 1
* gn_OdCur = ln
* DO _Odomet
* ENDDO
*
* ERROR CHECKING
* _Odomet assumes that all the variables are set correctly to avoid
* the overhead of type checking.
*
*-------------------------------------------------------------------------
IF gn_OdCur > 0
IF gn_OdCur <= gn_OdMax
*-- Display the odometer setting
@ 1, gn_OdLeft + 1 TO ;
1, INT( gn_OdLeft + 1 + ( gn_OdCur / gn_OdMax * 25 ) ) PANEL
RETURN
ELSE
*-- Display the odometer setting
@ 1, gn_OdLeft + 1 TO 1, gn_OdRight - 1 PANEL
DEACTIVATE WINDOW _Odomet
RELEASE WINDOW _Odomet
RESTORE SCREEN FROM Odomet
RELEASE SCREEN Odomet
SET COLOR OF BOX TO &gc_OdBoxCl
RETURN
ENDIF
ENDIF
IF gn_OdCur = 0
ln_LenOdom = 27
ln_Mess = 0
IF TYPE( "gc_OdText" ) = "C"
ln_Mess = LEN( gc_OdText )
IF ln_Mess <= ln_LenOdom
ln_Width = ln_LenOdom
ELSE
IF ln_Mess > 76
gc_OdText = LEFT( gc_OdText, 76 )
ln_Mess = 76
ENDIF
ln_Width = ln_Mess
ENDIF
ELSE
ln_Width = ln_LenOdom
ENDIF
ln_LeftCol = ((76 - ln_Width) + .5) / 2
ln_RightCol = (ln_Width + 83) / 2
gc_OdBoxCl = _ColorChk( "B" )
SET COLOR OF BOX TO w+/w
SAVE SCREEN TO Odomet
@ 10, ln_LeftCol + 2 FILL TO 16, ln_RightCol + 2 COLOR n+/n
DEFINE WINDOW _Odomet FROM 9, ln_LeftCol ;
TO 15, ln_RightCol DOUBLE ;
COLOR n/w
ln_width = ln_width + 2
ln_OdLeft = (ln_width - ln_LenOdom ) / 2
gn_OdLeft = ln_OdLeft
gn_OdRight = ln_OdLeft + ln_LenOdom
ACTIVATE WINDOW _Odomet
@ 0, ln_OdLeft SAY CHR( 218 ) COLOR n/w
@ 0, ln_OdLeft + 1 SAY REPLICATE( CHR( 196 ), ln_LenOdom - 1 ) COLOR n/w
@ 0, gn_OdRight SAY CHR( 191 ) COLOR w+/w
@ 1, ln_OdLeft SAY CHR( 179 ) COLOR n/w
@ 1, gn_OdRight SAY CHR( 179 ) COLOR w+/w
@ 2, ln_OdLeft SAY CHR( 192 ) COLOR n/w
@ 2, ln_OdLeft + 1 SAY REPLICATE( CHR( 196 ), ln_LenOdom - 1 ) COLOR w+/w
@ 2, gn_OdRight SAY CHR( 217 ) COLOR w+/w
IF TYPE( "gc_OdText" ) = "C"
@ 3, ( ln_Width - ln_Mess ) / 2 SAY gc_OdText COLOR n/w
ENDIF
ELSE
ENDIF
RETURN
*-- EOP: _Odomet
*'----------------------------------------------------------------------------
*' $Log: $
*'----------------------------------------------------------------------------